package oop.ex2.method;
import java.util.ArrayList;
import java.util.regex.*;

import oop.ex2.variables.BadVaraiableException;
import oop.ex2.variables.Variables;
import oop.ex2.variables.varType;

public class Method {
	private String name;
	private varType type=null;
	private ArrayList<Variables> inputVars=new ArrayList<Variables>();
	private ArrayList <String> methodBody=new ArrayList<String>();	

	public Method(String name, String type, String inputVars,ArrayList <String> methodLines) throws BadVaraiableException {
		this.name = name;
		if(type.equals("void"))
			this.type =varType.valueOf(type);
		String[] variables= inputVars.split(",");
		for (int i = 0; i < variables.length; i++) {
			variables[i].trim();
			Variables tempVar = new Variables(variables[i]);
			this.inputVars.add(tempVar);
		}
		this.methodBody=methodLines;
	}

	public ArrayList<String> getMethodBody() {
		return methodBody;
	}

	public String getName() {
		return name;
	}

	public varType getType() {
		return type;
	}

	public ArrayList<Variables> getInput() {
		return inputVars;
	}

	public void addInput(Variables variable) {
		this.inputVars.add(variable);
	}
	
}
